<%@ page language="java" %>
<%@ page import="com.scalar.chiptrack.commons.Constants,
                com.scalar.chiptrack.commons.SessionKeys,
                com.scalar.chiptrack.users.User,
                com.scalar.chiptrack.users.Functionality,
                com.scalar.chiptrack.utils.ConfigManager,
                com.scalar.chiptrack.utils.StringUtils,
				com.scalar.chiptrack.operations.packingslip.forms.PackingSlipForm,
				 java.util.ArrayList "%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/packingSlipMenu.do"/>

<html:html locale="true">
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% User user1 = (User)session.getAttribute (SessionKeys.USER_KEY); %>
<%String vendorLocation="";
    vendorLocation = (String) request.getAttribute("vendorLocationName");
    if ( ( vendorLocation == null )  || (vendorLocation.equals(null)) )
        vendorLocation = "";
    String currAction = request.getParameter("action");
    int[]  isDisableSubstitutableList = (int[]) request.getAttribute( "isDisableSubstitutableList");
    PackingSlipForm packingSlipForm = (PackingSlipForm) session.getAttribute("packingSlipForm");
%>
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</SCRIPT>
<SCRIPT language="JavaScript">

var errorMsg = "";
var errorMsg1 = "";

<%-- used for checking the length of a field--%>
var prevPrice = 0;
function fieldLength(value, disMessage, len)
{
    if( value.length > len )
    {
        errMsg = disMessage +" length cannot be greater than " + len + " charecters";
        return false;
    }
    else
    {
        return true;
    }
}

function resetValues()
{
        var shippingAddIdListObj = document.packingSlipForm.newShippingAddressId;
        if( ( typeof shippingAddIdListObj != "undefined" ) && ( typeof shippingAddIdListObj.options.length != "undefined" )  )
        {
            shippingAddIdListObj.options[0].selected = true
        }
}

function chjIndexAndaddOptionToSelect(indexElement)
{
    var optionValue1 = document.packingSlipForm[ 'lineitems[' + indexElement +'].part_Number'].value;
    var partNumberObj = document.packingSlipForm[ 'lineitems[' + indexElement +'].shipped_Part_Number'];
    if( partNumberObj.options.length == 0 )
    {
        addOption(partNumberObj, optionValue1, optionValue1, partNumberObj.options.length);
    }
}
function addOptionToSelect(aName, aValue, indexElement)
{
    var partNumberStr = aName + "";
    var partNumberObj = document.packingSlipForm[ 'lineitems[' + indexElement +'].qtyPulledSubstitutablePartNo'];
    var alreadyExistFlag = false;
    if( typeof partNumberObj != 'undefined' )
    {
        for( var i=0 ; i < partNumberObj.options.length ; i++ )
        {
            if( aValue ==  partNumberObj.options[i].value)
            {
                alreadyExistFlag = true;
                break;
            }
        }
    }
    if( alreadyExistFlag == false )
    {
        addOption(partNumberObj, partNumberStr, partNumberStr, partNumberObj.options.length);
    }
}

function addOption(aSelect, aName, aValue, anIndex)
{
   var aOption = new Option(aName, aValue)
   aSelect.options[anIndex] = aOption;
}

function deleteAllOptions(indexElement)
{

    var partNumberObj = document.packingSlipForm[ 'lineitems[' + indexElement +'].qtyPulledSubstitutablePartNo'];
    var optionValue1 = document.packingSlipForm[ 'lineitems[' + indexElement +'].part_Number'].value;

    if( typeof partNumberObj !='undefined' )
    {
        for( var j = partNumberObj.options.length ; j >= 0 ; j-- )
        {
             partNumberObj.options[j] = null;
        }
    }
}

function selectInventory( x )
{
    if ( document.packingSlipForm.selectLineitem.length == null )
    {
        if ( document.packingSlipForm.selectLineitem.checked )
        {
            document.packingSlipForm[ 'lineitems[' + x +'].qtyPulled'].disabled = false;
        }
        else
        {
			document.packingSlipForm[ 'lineitems[' + x +'].qtyPulled'].disabled = true;
            document.packingSlipForm[ 'lineitems[' + x +'].qtyPulled'].value	= 0;
        }
    }
    else
    {
        if ( document.packingSlipForm.selectLineitem[x].checked )
        {
            document.packingSlipForm[ 'lineitems[' + x +'].qtyPulled'].disabled = false;
        }
        else
        {
            document.packingSlipForm[ 'lineitems[' + x +'].qtyPulled'].disabled = true;
            document.packingSlipForm[ 'lineitems[' + x +'].qtyPulled'].value	= 0;
        }
    }
    checkMessage();
}

function generatePackingSlip()
{
    errorMsg	= "";
	errorMsg1	= "";
    errMsg      = "";
    document.packingSlipForm.txtErrMsgDetail.value = "";
    var actualShipDate = document.packingSlipForm.shipDate.value.trim();
	if ( checkFields('N') ==  true && checkLineItemDescription() == true && validTrackingNo() == true)
	{
		trimFields();
		enableFeilds();
		document.packingSlipForm.submit();
	}
	else
	{
  		var error  = document.getElementById("errors");
		var error1 = document.getElementById("errors1");
		error.innerHTML		= errorMsg ;
		error1.innerHTML	= errorMsg1 ;
		window.scrollBy(0,0);
	}
}

function checkLineItemDescription()
{

	var selLineItem = document.packingSlipForm.selectLineitem;
    var dropship = document.packingSlipForm.dropShippment.value;
    var status = document.packingSlipForm.status.value;
    var substitutePSIds = "";
    var substituteSelected = false;
    var flag = 1;

    if ( typeof  selLineItem.length == "undefined" )
    {
		if ( document.packingSlipForm[ 'lineitems[0].cool_Description'].value.length > 200 )
		{
           errorMsg = errorMsg + "<Li> Line Item Description should not exceed 200 characters </li>" ;
           flag = 0;
		}
    }
    else
    {
        for( var x = 0 ; x < selLineItem.length ; x++ )
		{
            var lineItemNo = document.packingSlipForm[ 'lineitems[' + x + '].lineitemNumber'].value;

			if ( document.packingSlipForm[ 'lineitems[' + x + '].cool_Description'].value.length > 200 )
			{
                errorMsg = errorMsg + "<Li> Line Item " + lineItemNo + " Description should not exceed 200 characters </li>" ;
                flag = 0;
			}
		}
    }
    if ( flag == 1 )
	{
		return true;
	}
	else
	{
		return false;
	}
}

function checkFields( ch )
{
	var flag = 1;
	var Dterms	= document.packingSlipForm.fob.value.trim();
	var weight  = document.packingSlipForm.weight.value.trim();
	var boxes   = document.packingSlipForm.noOfBoxes.value.trim();
    var actualShipDate = document.packingSlipForm.shipDate.value.trim();
	var dropship = document.packingSlipForm.dropShippment.value;
    var status   = document.packingSlipForm.status.value;
    var etdDate  = document.packingSlipForm.etd.value;
    var etaDate  = document.packingSlipForm.eta.value;

	document.packingSlipForm.comments.value = document.packingSlipForm.comments.value.trim();
    document.packingSlipForm.shippingInstructions.value=document.packingSlipForm.shippingInstructions.value.trim();
    var commentLength = document.packingSlipForm.comments.value.length;
    var shipInstructionLength = document.packingSlipForm.shippingInstructions.value.length;
    document.packingSlipForm.freightInstructions.value=document.packingSlipForm.freightInstructions.value.trim();
    var freightInstructionsLength = document.packingSlipForm.freightInstructions.value.length;

	errorMsg	= "";
	errorMsg1	= "";
    errMsg      = "";
	if ( ch == 'YN' )
	{
		if ( checkTrackingNo() == false )
		{
			flag = 0;
		}
	}

    if ( checkNull( Dterms ) == false )
	{
		errorMsg = errorMsg + "<Li> <bean:message key="label.sales.salesOrder.DeliveryTerms" />  Should not be empty </li>" ;
		flag = 0;
	}

   /* if( dropship == 'false'  )
    {
        if( chkDate( actualShipDate, "Ship Date", "Y" ) == false )
        {
            errorMsg = errorMsg + errMsg
            flag = 0;
        }
        else if ( isBeforeToday( actualShipDate, "Ship Date" ) ) // added by Ganesh on 21 th  aprl2007 as ship date can not be before today date
        {
            errorMsg = errorMsg + errMsg
            flag=0;
        }

    }
    else
    {*/
        if( chkDate( actualShipDate, "Ship Date", "Y" ) == false )
        {
            errorMsg = errorMsg + errMsg
            flag = 0;
        }
        else
        {
            var today = new Date();
            var actualShipDateArr		= actualShipDate.split("/");
            var inputDate = new Date(actualShipDateArr[2],actualShipDateArr[0]-1,actualShipDateArr[1]);
            var allowedElapsedDays = <%=ConfigManager.getPSShipDateAllowedElapsedDays()%>

            if ( allowedElapsedDays < daysElapsed( today, inputDate )  )
            {
                var allowedDate = new Date();
                allowedDate.setDate(allowedDate.getDate()-allowedElapsedDays);
                errorMsg = errorMsg + "<li>Ship date can not be less than '" +  (allowedDate.getMonth()+1) + "/" + allowedDate.getDate() + "/" + allowedDate.getYear() + "'";
                flag = 0;
            }

        }
       /* else if ( isBeforeToday( actualShipDate, "Ship Date" ) ) // added by Ganesh on 21 th aprl 2007 as schedule date can not be before today date
        {
            errorMsg = errorMsg + errMsg
            flag=0;
        }*/

    /*}*/

    if( chkDate( etdDate, "ETD Date", "N" ) == false )
    {
        errorMsg = errorMsg + errMsg
        flag = 0;
    }

    if( chkDate( etaDate, "ETA Date", "N" ) == false )
    {
        errorMsg = errorMsg + errMsg
        flag = 0;
    }

    if ( weight != "" )
	{
		if ( (checkWeight( weight ) == false) )
		{
			errorMsg = errorMsg + errMsg + "</li>" ;
			flag = 0;
		}
	}

	if ( boxes != "" )
	{
		if ( checkInteger( boxes, 'No.of Boxes', 'Y' ) == false )
		{
			errorMsg = errorMsg + "<li>" + errMsg + "</li>" ;
			flag = 0;
		}
	}

	if ( ch != 'YN' )
	{

		if ( checkSelect() == false )
	    {
			flag = 0;
		}
	}
    if ( commentLength > 300 )
	{
		errorMsg = errorMsg + "<li>  Comments should Not be greater than 300 Characters</li> ";
		flag = 0;
	}
    if ( shipInstructionLength > 300 )
	{
		errorMsg = errorMsg + "<li>  ShipingInstructions should Not be greater than 300 Characters</li> ";
		flag = 0;
	}
    if ( freightInstructionsLength > 300 )
	{
		errorMsg = errorMsg + "<li>  FreightInstructions should Not be greater than 300 Characters</li> ";
		flag = 0;
	}

	if ( flag == 1 )
	{
		return true;
	}
	else
	{
		return false;
	}
}

function checkWeight(weight)
{
    if ( (checkFloat( weight, 'Weight', 'Y' ) == false) || (fieldLength(weight,"Weight",8) == false) )
    {
        errMsg = "<li>" + errMsg;
        return false;
    }
   if( (is_Sp_Characters_frieght(weight) == false)  )
   {
        errMsg = "<li> Please enter a valid Weight";
        return false;
   }
   if( weight.length >= 6 )
    {
        var qtyValue = weight;
        var index = qtyValue.indexOf(".");
        if( index == -1 || index > 5 )
        {
            errMsg = "<li> Please enter a valid Weight (weight should be in XXXXX.XX format)";
            return false;
        }
    }
   return true;
}

function checkTrackingNo()
{
	var trackLen =  "" + document.packingSlipForm.tracking.length;
	var flag = 0;
    var vFlag = 0;

	if ( typeof document.packingSlipForm.tracking.length == "undefined"  )
	{
        document.packingSlipForm.tracking.value = document.packingSlipForm.tracking.value.trim();
		var trackValue  = document.packingSlipForm.tracking.value;
		if (  checkNull (trackValue ) == false  )
		{
			errorMsg = errorMsg + "<li>Please enter value for Freight Tracking Number</li>";
			document.packingSlipForm.tracking.focus();
			return false;
		}
        if(alphanumSpecial(trackValue,"Freight Tracking Number","N")==false)
		{
			errorMsg = errorMsg + "<li>Freight Tracking Number should be valid</li>";
			document.packingSlipForm.tracking.focus();
			return false;
		}
	}
	else
	{
		for (var j=0; j< parseInt(trackLen); j++ )
		{
            document.packingSlipForm.tracking[j].value = document.packingSlipForm.tracking[j].value.trim();
			var trackValue  = document.packingSlipForm.tracking[j].value;
			if (  checkNull( trackValue ) == false  )
			{
				flag = 1;
				break;
			}
            if(alphanumSpecial(trackValue,"Freight Tracking Number","N")==false)
            {
                vFlag = 1;
				break;
            }
		}

		if ( flag == 1 )
		{
			errorMsg = errorMsg + "<li>Please enter value for Freight Tracking Number</li>";
			document.packingSlipForm.tracking[0].focus();
			return false;
		}
        if ( vFlag == 1 )
		{
			errorMsg = errorMsg + "<li>Freight Tracking Number should be valid </li>";
			document.packingSlipForm.tracking[0].focus();
			return false;
		}
	}
    return true;
}

function validTrackingNo()
{
	var trackLen =  "" + document.packingSlipForm.tracking.length;
	var flag = 0;
    var vFlag = 0;

	if ( typeof document.packingSlipForm.tracking.length == "undefined"  )
	{
        document.packingSlipForm.tracking.value = document.packingSlipForm.tracking.value.trim();
		var trackValue  = document.packingSlipForm.tracking.value;
        if(alphanumSpecial(trackValue,"Freight Tracking Number","N")==false)
		{
			errorMsg = errorMsg + "<li>Freight Tracking Number should be valid</li>";
			document.packingSlipForm.tracking.focus();
			return false;
		}
	}
	else
	{
		for (var j=0; j< parseInt(trackLen); j++ )
		{
            document.packingSlipForm.tracking[j].value = document.packingSlipForm.tracking[j].value.trim();
			var trackValue  = document.packingSlipForm.tracking[j].value;
            if(alphanumSpecial(trackValue,"Freight Tracking Number","N")==false)
            {
                vFlag = 1;
				break;
            }
		}
        if ( vFlag == 1 )
		{
			errorMsg = errorMsg + "<li>Freight Tracking Number should be valid </li>";
			document.packingSlipForm.tracking[0].focus();
			return false;
		}
	}
    return true;
}

function checkSelect()
{
	var flag = 1;
	var lineItemCheck = "" +  document.packingSlipForm.selectLineitem.length;

    var dropship = document.packingSlipForm.dropShippment.value;
    var status = document.packingSlipForm.status.value;
    var hiddenQtyPulled;

    if ( document.packingSlipForm.selectLineitem.length == null )
	{
		if ( document.packingSlipForm.selectLineitem.checked == false )
		{
			errorMsg1 = errorMsg1 + " <li> Please select inventory for atleast one line item  </li>";
			flag = 0;
		}
		else
		{
			if ( parseInt( eval(document.packingSlipForm[ 'lineitems[' + 0 +'].qtyPulled'].value) ) == 0 )
		    {
				errorMsg1 = errorMsg1 + " <li> Quantity shipped must be greater than 0 </li> ";
                flag = 0;
			}
            else
            {
				if ( checkInteger( document.packingSlipForm[ 'lineitems[' + 0 +'].qtyPulled'].value, 'Quantity Shipped', 'Y' ) == false )
				{
					  errorMsg1 = errorMsg1 + "<li>" + errMsg + "</li>" ;
					  flag = 0;
				}
				else
				{
                     hiddenQtyPulled = document.packingSlipForm[ 'lineitems[0].hiddenQtyPulled'].value;
                     if( dropship == "true" && status == "ISSUED" )
                     {
                         if ( parseInt(hiddenQtyPulled)  != parseInt( document.packingSlipForm[ 'lineitems[' + 0 +'].qtyPulled'].value )  )
                         {
                             if (  parseInt(hiddenQtyPulled)  < parseInt( document.packingSlipForm[ 'lineitems[' + 0 +'].qtyPulled'].value )  )
                             {
                                flag = 0;
                                errorMsg1  = errorMsg1 + "<li> Quantity shipped should be less than or equal to Quantity to be shipped </li>";
                             }
                             else
                             {
                                flag = 1;
                             }
                         }
                     }
                     else
                     {
                         if ( ( parseInt(document.packingSlipForm[ 'lineitems[' + 0 +'].qtyToShip'].value ) + parseInt( document.packingSlipForm[ 'lineitems[' + 0 +'].orginalQtyPulled'].value )  ) < parseInt( document.packingSlipForm[ 'lineitems[' + 0 +'].qtyPulled'].value )  )
                         {
                            flag = 0;
                            errorMsg1  = errorMsg1 + "<li> Quantity shipped should be less than or equal to Quantity to be shipped </li>";
                         }
                         else
                         {
                            flag = 1;
                         }
                     }
				}
            }
		}
	}
	else
	{
		var fg = 0;
		for ( var k = 0; k < parseInt( lineItemCheck ) ; k++ )
		{
			if ( document.packingSlipForm.selectLineitem[k].checked == true )
			{
				fg =1;
				if (  parseInt(document.packingSlipForm[ 'lineitems[' + k +'].qtyPulled'].value) == 0 )
				{
					flag = 0 ;
					errorMsg1 = "<li> Quantity should be greater than 0 </li> ";
                    break;
				}
				else
				{
                        if ( checkInteger( document.packingSlipForm[ 'lineitems[' + k +'].qtyPulled'].value, 'Quantity Shipped', 'Y' ) == false )
                        {
                          errorMsg1 = errorMsg1 + "<li>" + errMsg + "</li>" ;
                          flag = 0;
                          break ;
                        }
                        else
                        {
                            hiddenQtyPulled = document.packingSlipForm[ 'lineitems[' + k +'].hiddenQtyPulled'].value;
                            if( dropship == "true" && status == "ISSUED" )
                            {
                                if ( parseInt(hiddenQtyPulled)  != parseInt( document.packingSlipForm[ 'lineitems[' + k +'].qtyPulled'].value )  )
                                {
                                    if ( parseInt(hiddenQtyPulled) < parseInt( document.packingSlipForm[ 'lineitems[' + k +'].qtyPulled'].value )  )
                                    {
                                        flag = 0;
                                        errorMsg1  = errorMsg1 + "<li> Quantity shipped should be less than or equal to Quantity to be shipped  for lineItem "+ (k+1) + "</li>";
                                    }
                                    else
                                    {
                                        flag = 1;
                                    }
                                }
                            }
                            else
                            {
                                if ( ( parseInt(document.packingSlipForm[ 'lineitems[' + k +'].qtyToShip'].value ) + parseInt( document.packingSlipForm[ 'lineitems[' + k +'].orginalQtyPulled'].value )  ) < parseInt( document.packingSlipForm[ 'lineitems[' + k +'].qtyPulled'].value )  )
                                {
                                    flag = 0;
                                    errorMsg1  = errorMsg1 + "<li> Quantity shipped should be less than or equal to Quantity to be shipped  for lineItem "+ (k+1) + "</li>";
                                    break ;
                                }
                                else
                                {
                                    flag = 1;
                                }
                            }
                        }
				}
			}  // 	end if
	    else
			{
			       if (  parseInt(document.packingSlipForm[ 'lineitems[' + k +'].qtyPulled'].value) > 0 )
                   {
                           errorMsg1 = errorMsg1 +"<li> Check the  Line item or else make Quantity to be shipped as zero for lineitem " +(k+1) +"</li>";
                            flag=0; fg=1;
                            break;
                    }
			}

	    }//end for
    }//end else

	if ( fg == 0 )
    {
		errorMsg1  =  "<li> please Select Atleast One Line Item</li>";
	    flag = 0;
	}

	if ( flag == 0 )
	{
		return false;
	}
	else
	{
		return true;
	}
}

function checkNull( values )
{
	 var len = values.length;
	 var str = "";
 	 for ( var k = 0; k < len; k++ )
	 {
		var ch = values.charCodeAt(k);
	 	if ( ch == 13 || ch == 10 || ch== 32 )   //check for enter key and spaces
			continue;
		else
			str = str + values.charAt( k );
	}

	if ( str == "" )
		return false;
	else
		return true;
}

function trimFields()
{
	document.packingSlipForm.fob.value       = document.packingSlipForm.fob.value.trim();
	document.packingSlipForm.weight.value    = document.packingSlipForm.weight.value.trim();
	document.packingSlipForm.noOfBoxes.value = document.packingSlipForm.noOfBoxes.value.trim();
}

function enableFeilds()
{
	var form  = document.packingSlipForm;
	var count =	form.count.value;
	form.label.disabled = false;
	form.salesOrderNumber.disabled = false;
	form.customerName.disabled = false;
	form.customerPO.disabled = false;
	form.repOffice.disabled = false;
	form.fob.disabled = false;
	form.shippedVia.disabled = false;
	form.billingAddress.disabled = false;
	form.shippingAddress.disabled = false;
	form.shippingInstructions.disabled = false;
    form.contactPerson.disabled = false;
    var optionsCount = 0;

	for( i = 0; i < count; i++ )
    {
		form[ 'lineitems[' + i +'].qtyPulled'].disabled = false;
	}

    if( form.status.value != "SHIPPED" )
    {
        if (typeof document.packingSlipForm.selectLineitem.length == "undefined" )
        {
            if ( document.packingSlipForm.selectLineitem.checked == true )
            {
                var shippedPartNoObj = document.packingSlipForm['lineitems[0].shipped_Part_Number'];
                shippedPartNoObj.disabled = false;
            }
        }
        else
        {
            var fg = 0;
            var lineItemCheck = "" +  document.packingSlipForm.selectLineitem.length;
            for ( var k = 0; k < parseInt( lineItemCheck ) ; k++ )
            {
                if ( document.packingSlipForm.selectLineitem[k].checked == true )
                {
                    var shippedPartNoObj = document.packingSlipForm[ 'lineitems[' + k + '].shipped_Part_Number'];
                    shippedPartNoObj.disabled = false;
                }
            }
        }
    }
}

function selectPackingSlip()
{
    if( document.packingSlipForm.otherCustomerShippingId.value != -1 )
    {
         window.location = "<%=chipTracContext%>/shippingAdvise.do?ps="+document.packingSlipForm.otherCustomerShippingId.value+"&cstKey=0";
    }
}

function sendMail( salesOrderId, customerShippingId, locationId )
{
    newWindow = window.open ('<%=chipTracContext%>/sendMail.do?salesOrderId=' + salesOrderId + '&customerShippingId=' + customerShippingId + '&locationId=' + locationId,'sendMailPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
    newWindow.focus();
}

function cancelAndGoBack()
{
    document.packingSlipForm.action = "<%=chipTracContext%>/extUserSearchPackingSlip.do";
    document.packingSlipForm.submit();
}

function checkNoBoxes()
{
	var flag = true;
	var boxes   = document.packingSlipForm.noOfBoxes.value.trim();
    document.packingSlipForm.noOfBoxes.value = document.packingSlipForm.noOfBoxes.value.trim();
	if ( boxes == "" )
	{
		errorMsg = errorMsg + "<li>Please enter value for No. of Boxes</li> ";
	    flag = false;
	}
    else
	{
		if ( checkInteger( boxes, 'No.of Boxes', 'Y' ) == false )
		{
			errorMsg = errorMsg + "<li>" + errMsg + "</li>" ;
			flag = false;
	 	}
	}
	return flag;
}


var dateElement = "";
function openCalendar( dateValue )
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.focus();
}

function assignDate( passedValue )
{
    dateElement.value=passedValue;
    window.focus();
}

function addTrackingNumberField( fontId )
{
    var row = document.getElementById(fontId);
    var table = row.parentElement;
    var newRow = table.insertRow(row.rowIndex);
    var td = newRow.insertCell();
    td.innerHTML ='<font class="NArialL"><font color=green>Way Bill:</font></font>';
    td = newRow.insertCell();
    td.innerHTML = '<input type=text name="tracking" class=txfield size="20" maxlength="50" />';
    td = newRow.insertCell();
    td.colSpan = 4;
}

function showErrorReportPage(){ }


function checkLength(element, size)
{
    if(	element.value.length >= size )
	{
		event.returnValue = false;
	}
}

function checkMessage()
{
    var error1	= document.getElementById("errors1");
    var lineItemCheck = "" +  document.packingSlipForm.selectLineitem.length;

    if( lineItemCheck == "undefined" )
    {
        if ( document.packingSlipForm.selectLineitem.checked == true )
        {
            errorMsg1 = "";
            error1.innerHTML	= errorMsg1 ;
            document.packingSlipForm.txtErrMsgDetail.value="";
        }
    }
    else
    {
        for ( var k = 0; k < parseInt( lineItemCheck ) ; k++ )
        {
            if ( document.packingSlipForm.selectLineitem[k].checked == true )
            {
                document.packingSlipForm.txtErrMsgDetail.value="";
                errorMsg1 = "";
                error1.innerHTML	= errorMsg1 ;

            }
        }
    }
}

function chkQtyPulledValidation(index)
{

    document.packingSlipForm.txtErrMsgDetail.value = "";
    if ( document.packingSlipForm.selectLineitem.checked == true )
    {
        var found = false;

        var shippedPartNoObj = document.packingSlipForm[ 'lineitems[' + index +'].shipped_Part_Number'];
        var qtyPulledshippedPartNoObj = document.packingSlipForm[ 'lineitems[' + index +'].qtyPulledSubstitutablePartNo'];

        for(var i = 0 ; i < shippedPartNoObj.length ; i++ )
        {
           if( shippedPartNoObj.options[i].selected == true )
           {
                for(var k = 0 ; k < qtyPulledshippedPartNoObj.length ; k++ )
                {
                    if( shippedPartNoObj.options[i].text == qtyPulledshippedPartNoObj.options[k].text )
                    {
                        document.packingSlipForm.txtErrMsgDetail.value	= "Please reset the quantity pulled" ;
                        return false;
                    }
                }
           }
        }
    }
    return true;
}
var defaultStr = "";
function sendOptionElementLeftToRight ( index )
{
    var list1 = document.packingSlipForm[ 'lineitems[' + index +'].substitute_Part_Number'];
    var list2 = document.packingSlipForm[ 'lineitems[' + index +'].shipped_Part_Number'];
    if ( list_copySelected ( list1,list2, defaultStr ) > 0 )
    {
        list_deleteSelected ( list1, defaultStr );
    }
}

function sendOptionElementRightToLeft ( index )
{
    var list1 = document.packingSlipForm[ 'lineitems[' + index +'].substitute_Part_Number'];
    var list2 = document.packingSlipForm[ 'lineitems[' + index +'].shipped_Part_Number'];
    if( chkQtyPulledValidation(index) == true )
    {
        if ( list_copySelected ( list2, list1, defaultStr ) > 0 )
        {
            list_deleteSelected ( list2, defaultStr );
        }
    }
}

function list_copySelected(list1, list2, defaultStr)
{

    if ( list1 == null || list2 == null ){
        return -1;
    }
    else if ( list1.length == 1 && list1.options[0].selected && list1.options[0].text == defaultStr){
        return -2;
    }

    var copyCount = 0;

    for (var i = 0; i < list2.length; i++ ){
        list2.options[i].selected = false;
    }

    for (var i = 0; i < list1.length; i++ ){
        if ( list1.options[i].selected ){
            list2.options[list2.length] = new Option(list1.options[i].text, list1.options[i].value);
            copyCount++;
        }
    }

    if ( list2.length > 1 && list2.options[0].text == defaultStr ){
        list2.options[0] = null;
    }

    return copyCount;
}

function list_deleteSelected(list1, defaultStr)
{
    if ( list1 == null ){
        return -1;
    }
    else if ( list1.length == 1 && list1.options[0].selected && list1.options[0].text == defaultStr){
        return -2;
    }

    var deleteCount = 0;
    var sel = new Array(list1.length);

    for (var i = 0; i < list1.length; i++ ){
        if ( list1.options[i].selected ){
            list1.options[i].selected = false;
            sel[deleteCount++] = i;
        }
    }

    for (var i = deleteCount - 1; i > -1 ; i-- ){
        list1.options[sel[i]] = null;
    }

    if ( list1.length == 0 )
        list1.options[0] = new Option(defaultStr, defaultStr);

    return deleteCount;
}
</SCRIPT>
</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onLoad="javascript:resetValues();">

<!-- Top Header Start-->
        <%@ include file="/jsp/includes/extHeader.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
	<TBODY>
	<TR>
		<td width='180' valign='top' background="<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif">

<!-- Side Navigation start -->
        <%@ include file="/jsp/admin/externaluser_menu.jsp" %>
<!-- end of the side navigations -->

		</td>
		<TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
		<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
		<TD valign="top" width="100%"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>

<!-- body starts -->
			<html:form name="packingSlipForm" type="com.scalar.chiptrack.operations.packingslip.forms.PackingSlipForm" action="/vendorPackingSlip.do?action=save" scope="request">
			<table border="0" align="center" width="98%">
				<tr>
					<td align="center" valign="center" width="80%"><font class="NArialW">&nbsp;&nbsp;Packing Slip</font></td>
				</tr>
			</table>

			<!-- HIDDEN VARIBLES -->
            <input type="hidden" name="customerShippingId" value="<%= packingSlipForm.getCustomerShippingId()%>"/>
            <input type="hidden" name="salesOrderId" value="<%= packingSlipForm.getSalesOrderId()%>"/>
			<html:hidden name="packingSlipForm" property="shippingMethod" />
            <html:hidden name="packingSlipForm" property="shippingAccount" />
			<html:hidden name="packingSlipForm" property="shippingFromAddressId" />
			<html:hidden name="packingSlipForm" property="shippingToAddressId" />
			<html:hidden name="packingSlipForm" property="dropShippment"/>
			<html:hidden name="packingSlipForm" property="status"/>
            <html:hidden name="packingSlipForm" property="shippingFromLocationId"/> <%--Added by krishna Prasad on 27 May 2004--%>
			<input type="hidden" name="autoConfirmPackingSlip" value="<%=request.getAttribute ("AUTO_CONFIRM_PACKING_SLIP")%>"/>
            <input type="hidden" name="allowNewShippingAddressEdit" value="true"/>

			<table border="0" width="90%" align="top">
				<%
					if ( !user1.isActionAllowed ( Functionality.PACKING_SLIP, User.USER_ACTION_MODIFY  )  )
					{
				%>
				<tr><td class="NArialS"><font color="blue"><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></td></tr>
				<%
					}
				%>
				<TR><TD width="50%" valign="top">
				<INPUT align=left border=0 maxLength=100 name="txtErrMsg" size=100
                        style="BORDER-BOTTOM: thin; BORDER-LEFT-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP: thin; CLEAR: none; COLOR: red;font-family: arial;font-size: 10pt;font-weight:bold " value="" readOnly>
				</TD></TR>

			</table>
			<table border="0" width="90%" align=right class="NArialL">
				<tr>
					<td colspan="6"  class="NArialL"><FONT id="errors" color="FF0000"></FONT></td>
				</tr>
				<tr>
					<td width="21%"><font class="NArialL">PackingSlip Label:</font></td>
					<td width="21%">
						<html:text disabled="true" name="packingSlipForm"  property="label" size="20" maxlength="50" styleClass="disabledtxfield"/>
                    </td>
					<td width="3%">&nbsp;</td>
					<td width="21%"><font class="NArialL">Other Packing Slips:</font>&nbsp;</td>
					<td width="21%">
					<html:select name="packingSlipForm" property="otherCustomerShippingId" onchange="selectPackingSlip()"  styleClass="NArialL" >
							<option value="-1" selected>-- Other Packingslips --</option>
							<html:options collection="packingSlipListBySalesOrderId" property="value" labelProperty="label"/>
                    </html:select>
					</td>
					<td width="3%">&nbsp;</td>
				</tr>
			    <tr>
					<td width="21%"><font class="NArialL">Customer PO:</font></td>
					<td width="21%"><html:text disabled="true" name="packingSlipForm"  property="customerPO" size="20" styleClass="disabledtxfield"/></td>
					<td width="3%">&nbsp;</td>
					<td width="21%"><font class="NArialL">Sales Order No:</font></td>
					<td width="21%"><html:text disabled="true" name="packingSlipForm"  property="salesOrderNumber" size="20" styleClass="disabledtxfield"/></td>
					<td width="3%">&nbsp;</td>
				</tr>
				<tr>
			        <td width="21%"><font class="NArialL">Customer Name:</font></td>
					<td width="21%"><html:text disabled="true" name="packingSlipForm"  property="customerName" size="20" maxlength="50" styleClass="disabledtxfield"/></td>
					<td width="3%">&nbsp;</td>
					<td width="21%"><font class="NArialL">Shipping Contact Person:</font></td>
					<td width="21%">
                        <html:text name="packingSlipForm"  property="contactPerson" size="20" maxlength="50" styleClass="disabledtxfield" disabled="true"/>
					</td>
					<td width="3%">&nbsp;</td>
				</tr>
				<tr>
					<td width="21%"><font class="NArialL">Regional Rep:</font></td>
					<td width="21%"><html:text name="packingSlipForm" disabled="true" property="repOffice" size="20" maxlength="50" styleClass="disabledtxfield"/>
					</td>
					<td width="3%">&nbsp;</td>				    
                    <% if( ConfigManager.getShowPackageDimensionInPackingSlip() ) { %>
                    <td width="21%"><font class="NArialL">Net Weight:</font></td>
                    <% } else { %>
                    <td width="21%"><font class="NArialL">Weight:</font></td>
                    <% } %>
                    <td width="21%">
					    <html:text name="packingSlipForm"  property="weight" size="20" maxlength="8" styleClass="txfield"  onkeypress="javascript:restrictCharacters(this,5,2)" onkeyup="javascript:restrictAmt(this,5,2)"/>
					    <html:select name="packingSlipForm" property="weightType" styleClass="txfield">
                            <html:options collection="weightMeasurementList" property="value" labelProperty="label" />
                        </html:select>
					</td>
					<td width="3%">&nbsp;</td>
				</tr>
                <tr>
					<td width="21%" class="NArialL">Package Dimension:</td>
					<td width="21%">
                        <% if( packingSlipForm.getAction().equalsIgnoreCase( "viewShipped" ) ) { %>
                            <html:text name="packingSlipForm" property="packageDimension" size="20" maxlength="20" disabled="true" styleClass="txfield"/>
							<html:select name="packingSlipForm" property="uomPgkDimension" styleClass="txfield">
				                <html:options collection="uomPgkDimensionList" property="value" labelProperty="label" />
			                </html:select>
                        <% } else { %>
                            <html:text name="packingSlipForm" property="packageDimension" size="20" maxlength="20" styleClass="txfield"/>
							<html:select name="packingSlipForm" property="uomPkgDimension" styleClass="txfield">
				                <html:options collection="uomPgkDimensionList" property="value" labelProperty="label" />
			                </html:select>
                        <% } %>
					</td>
					<td width="3%">&nbsp;</td>
				    <td width="21%"><font class="NArialL">Gross Weight:</font></td>
					<td width="21%">
                        <% if( packingSlipForm.getAction().equalsIgnoreCase( "viewShipped" ) ) { %>
                            <html:text name="packingSlipForm" property="grossWeight" size="20" maxlength="8" disabled="true" styleClass="txfield"  onkeypress="javascript:restrictCharacters(this,5,2)" onkeyup="javascript:restrictAmt(this,5,2)"/>
                        <% } else { %>
                            <html:text name="packingSlipForm" property="grossWeight" size="20" maxlength="8" styleClass="txfield"  onkeypress="javascript:restrictCharacters(this,5,2)" onkeyup="javascript:restrictAmt(this,5,2)"/>
                        <% } %>
                    </td>
					<td width="3%">&nbsp;</td>
				</tr>
				<tr>
					<td width="21%"><font class="NArialL"><bean:message key="label.sales.salesOrder.DeliveryTerms" />:</font><font color="RED" size="1"><B>*</B></font></td>
					<td width="21%">
						<html:text name="packingSlipForm"  property="fob" size="20" maxlength="50" styleClass="txfield"/>
					</td>
					<td width="3%">&nbsp;</td>
					<td width="21%"><font class="NArialL">No. Of Boxes:</font><font color="RED" size="1"><B>
					<logic:equal name="packingSlipForm" property="action" value="view"> *
					</logic:equal>
					</B></font>
					</td>
					<td width="21%">

					<%
                            if( "0".equals( ( packingSlipForm.getNoOfBoxes() == null ? "" : packingSlipForm.getNoOfBoxes() ) ) ) {
					%>
                    		<html:text name="packingSlipForm"  property="noOfBoxes" size="20" maxlength="8" styleClass="txfield" value=""/>
                    <%      }
                            if( ! ( "0".equals( ( packingSlipForm.getNoOfBoxes() == null ? "" : packingSlipForm.getNoOfBoxes() ) ) ) )
                            {
                    %>
                    		<html:text name="packingSlipForm"  property="noOfBoxes" size="20" maxlength="8" styleClass="txfield"/>
                    <%      } %>

					</td>
					<td width="3%">&nbsp;</td>
				</tr>

				<tr>
					<td width="21%"><font class="NArialL">Way Bill:</font></td>
					<td width="21%" valign=center>
					<logic:iterate name="packingSlipForm" property="tracking" id="track" length="1">
						<input type="text" name="tracking" size="20" maxlength="50" class="txfield" value='<bean:write name="track"/>'>
		            </logic:iterate>
					<a href="javascript:addTrackingNumberField('font1');" onMouseOver="window.status='Click to Add New Tracing Number';return true" onMouseOut="window.status='';return true"title='Click here to add new Trackig Number'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align=center></a>
					</td>
					<td width="3%">&nbsp;</td>
					<td width="21%"><font class="NArialL">Shipped VIA:</font></td>
					<td width="21%"><html:text name="packingSlipForm" property="shippedVia" size="20" maxlength="50" styleClass="txfield"/></td>
					<td width="3%">&nbsp;</td>
				</tr>
                <logic:iterate name="packingSlipForm" property="tracking" id="track" offset="1">
                    <tr>
                        <td width="22%"><font class="NArialL">Freight Tracking No:</font></td>
                        <td width="21%">
                            <input type=text name="tracking" class=txfield size="20" maxlength="50" value='<bean:write name="track"/>'/></td>
                        <td colspan=4>&nbsp;</td>
                    </tr>
                </logic:iterate>

				<tr id="font1"><td colspan="6" id="font1"></td></tr>
                <tr>
					<td width="21%" class="NArialL">MAWB No:</td>
					<td width="21%">
                        <% if( packingSlipForm.getAction().equalsIgnoreCase( "viewShipped" ) ) { %>
                            <html:text name="packingSlipForm" property="mawb" size="20" maxlength="50" disabled="true" styleClass="txfield"/>
                        <% } else { %>
                            <html:text name="packingSlipForm" property="mawb" size="20" maxlength="50" styleClass="txfield"/>
                        <% } %>
					</td>
					<td width="3%">&nbsp;</td>
				    <td width="21%"><font class="NArialL">HAWB No:</font></td>
					<td width="21%">
                        <% if( packingSlipForm.getAction().equalsIgnoreCase( "viewShipped" ) ) { %>
                            <html:text name="packingSlipForm" property="hawb" size="20" maxlength="50" disabled="true" styleClass="txfield" />
                        <% } else { %>
                            <html:text name="packingSlipForm" property="hawb" size="20" maxlength="50" styleClass="txfield" />
                        <% } %>
                    </td>
					<td width="3%">&nbsp;</td>
				</tr>
                <tr>
					<td width="21%" class="NArialL">Flight-1 No:</td>
					<td width="21%">
                        <% if( packingSlipForm.getAction().equalsIgnoreCase( "viewShipped" ) ) { %>
                            <html:text name="packingSlipForm" property="flightNumberOne" size="20" maxlength="50" disabled="true" styleClass="txfield"/>
                        <% } else { %>
                            <html:text name="packingSlipForm" property="flightNumberOne" size="20" maxlength="50" styleClass="txfield"/>
                        <% } %>
					</td>
					<td width="3%">&nbsp;</td>
				    <td width="21%"><font class="NArialL">Flight-2 No:</font></td>
					<td width="21%">
                        <% if( packingSlipForm.getAction().equalsIgnoreCase( "viewShipped" ) ) { %>
                            <html:text name="packingSlipForm" property="flightNumberTwo" size="20" maxlength="50" disabled="true" styleClass="txfield" />
                        <% } else { %>
                            <html:text name="packingSlipForm" property="flightNumberTwo" size="20" maxlength="50" styleClass="txfield" />
                        <% } %>
                    </td>
					<td width="3%">&nbsp;</td>
				</tr>
                <tr>
					<td width="21%" class="NArialL">ETD:</td>
					<td width="21%">
                        <% if( packingSlipForm.getAction().equalsIgnoreCase( "viewShipped" ) ) { %>
                            <html:text name="packingSlipForm" property="etd" size="20" maxlength="50" disabled="true" styleClass="txfield"/>
                        <% } else { %>
                            <html:text name="packingSlipForm" property="etd" size="20" maxlength="50" styleClass="txfield"/>
                            <a href="javascript:openCalendar( document.packingSlipForm.etd )">
								<img onMouseOver="window.status='Click  to select date';return true" onMouseout="window.status='';return 	true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20>
							</a>
                        <% } %>
					</td>
					<td width="3%">&nbsp;</td>
				    <td width="21%"><font class="NArialL">ETA:</font></td>
					<td width="21%">
                        <% if( packingSlipForm.getAction().equalsIgnoreCase( "viewShipped" ) ) { %>
                            <html:text name="packingSlipForm" property="eta" size="20" maxlength="50" disabled="true" styleClass="txfield" />
                        <% } else { %>
                            <html:text name="packingSlipForm" property="eta" size="20" maxlength="50" styleClass="txfield" />
                            <a href="javascript:openCalendar( document.packingSlipForm.eta )">
								<img onMouseOver="window.status='Click  to select date';return true" onMouseout="window.status='';return 	true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20>
							</a>
                        <% } %>
                    </td>
					<td width="3%">&nbsp;</td>
				</tr>
                <tr>
					<td width="21%"><font class="NArialL">Billing Address:</font></td>
					<td width="21%">
						<html:textarea disabled="true" rows="12" name="packingSlipForm" property="billingAddress" cols="30" styleClass="disabledtxfield"/>
					</td>
                    <nested:hidden property="billingAddressObject.address1"/>
                    <nested:hidden property="billingAddressObject.address2"/>
                    <nested:hidden property="billingAddressObject.address3"/>
                    <nested:hidden property="billingAddressObject.address4"/>
                    <nested:hidden property="billingAddressObject.city"/>
                    <nested:hidden property="billingAddressObject.state"/>
                    <nested:hidden property="billingAddressObject.zipCode"/>
                    <nested:hidden property="billingAddressObject.country"/>
                    <nested:hidden property="billingAddressObject.phoneNumber"/>
                    <nested:hidden property="billingAddressObject.faxNumber"/>
                    <nested:hidden property="billingAddressObject.email"/>
                    <nested:hidden property="billingAddressObject.contactPerson"/>
                    <nested:hidden property="billingAddressObject.cellNumber"/>
                    <td width="3%">&nbsp;</td>
					<td width="21%"><font class="NArialL">Shipping Address:</font></td>
					<td width="21%">
						<html:textarea disabled="true" rows="12" name="packingSlipForm" property="shippingAddress" cols="30" styleClass="disabledtxfield"/>
					</td>
                    <nested:hidden property="shippingAddressObject.address1"/>
                    <nested:hidden property="shippingAddressObject.address2"/>
                    <nested:hidden property="shippingAddressObject.address3"/>
                    <nested:hidden property="shippingAddressObject.address4"/>
                    <nested:hidden property="shippingAddressObject.city"/>
                    <nested:hidden property="shippingAddressObject.state"/>
                    <nested:hidden property="shippingAddressObject.zipCode"/>
                    <nested:hidden property="shippingAddressObject.country"/>
                    <nested:hidden property="shippingAddressObject.phoneNumber"/>
                    <nested:hidden property="shippingAddressObject.faxNumber"/>
                    <nested:hidden property="shippingAddressObject.email"/>
                    <nested:hidden property="shippingAddressObject.contactPerson"/>
                    <nested:hidden property="shippingAddressObject.cellNumber"/>
                    <td width="3%">&nbsp;</td>
				</tr>
				<tr>
					<td width="21%"><font class="NArialL">Ship Date(mm/dd/yyyy):</font></td>
					<td width="21%"><INPUT type="text" name="shipDate"  size="11" maxlength="10" Class="txfield">
                        <a href="javascript:openCalendar( document.packingSlipForm.shipDate )">
								<img onMouseOver="window.status='Click  to select date';return true" onMouseout="window.status='';return 	true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20>
							</a>
                    </td>
					<td width="3%">&nbsp;</td>
					<td width="21%" class="NArialL">Invoice #:</td>
					<td width="21%">
                     <html:text name="packingSlipForm" property="invNo" maxlength="50" styleClass="txfield" disabled="true"/>
                    </td>
					<td width="3%">&nbsp;</td>
				</tr>

				<tr>
					<td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
				</tr>
                <tr>
					<td width="21%" class="NArialL">Vendor Location:</td>
					<td colspan=5>
                        <input type="text" name ="vendorLocation" value = "<%=vendorLocation%>"  Class="txfield" disabled>
                    </td>
                </tr>
                <%--<tr>
					<td width="21%">&nbsp;</td>
					<td width="21%">&nbsp;</td>
                    <td width="3%">&nbsp;</td>
					<td width="21%" class="NArialL">Gross Weight :</td>
					<td width="21%">
                        <html:text name="packingSlipForm" property="grossWeight" maxlength="50" styleClass="txfield"/>
                    </td>
					<td width="3%">&nbsp;</td>
                </tr>--%>
                <tr>
					<td colspan="3"><font class="NArialL"><bean:message key="label.sales.shippingInstructions" /></font></td>
					 <td colspan="3"><font class="NArialL">Freight Instructions:</font></td>
					</tr>
				<tr>
                    <td colspan="3">
                        <html:textarea rows="6"  name="packingSlipForm" property="shippingInstructions" cols="50" styleClass="txfield" onkeypress="javascript:checkLength(this, 300)" />
	 				</td>
					<td colspan="3">
                        <html:textarea rows="6"  name="packingSlipForm" property="freightInstructions" cols="50" styleClass="txfield"   onkeypress="javascript:checkLength(this, 300)" />
	 				</td>
                </tr>
                <tr>
					 <td colspan="3"><font class="NArialL">Comments:</font></td>
                     <td colspan="3">&nbsp;</td>
				</tr>
				<tr>
					<td colspan="3">
                        <html:textarea rows="6" name="packingSlipForm" property="comments" cols="50" styleClass="txfield" onkeypress="javascript:checkLength(this, 300)" />
	 				</td>
                    <td colspan="3">&nbsp;</td>
                </tr>
				<tr>
					<td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
				</tr>
                <tr>
					<td colspan=6>
                    <% if( request.getAttribute("HoldLineItemList") != null ) { %>
                        <jsp:include page="packing_slip_line_items.jsp" flush="true" />
                    <% } %>
                    </td>
				</tr>
                <tr>
					<td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
				</tr>
				<tr>
					<td colspan=6><chiptrack:errors styleClass="NArialL"/></td>
				</tr>
				<tr>
					<td colspan=6>
					<INPUT align=left border=0 maxLength=100 name="txtErrMsgDetail" size=100 style="BORDER-BOTTOM: thin; BORDER-LEFT-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP: thin; CLEAR: none; COLOR: red;font-family: arial;font-size: 10pt;font-weight:bold " value="" readOnly>
					</td>
				</tr>
				<tr>
					<td colspan='6' class="NArialL"><FONT id="errors1" size="-2" color="FF0000"></FONT></td>
				</tr>
				<tr>
					<td colspan=6>
						<table border="0" width="98%" bordercolor="#FFFFFF">
							<tr>
                                <td width="4%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Select</font></td>
								<td width="4%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Line Item</font></td>
                                <% if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MFG_PARTNO_PACKINGSLIP ) ) { %>
								<td width="15%" align="center" bgcolor="#993333">
									<font class="NArialL"><font color="#FFFFFF"><bean:message key="label.mfgPartNumber"/></font></font>
								</td>
                                <% if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MRKT_PARTNO_PACKINGSLIP ) ) { %>
                                <td width="15%" align="center" bgcolor="#993333">
									<font class="NArialL"><font color="#FFFFFF"><bean:message key="label.mktgPartNumber"/></font></font>
								</td>
                                <% } %>
                                <td width="15%" align="center" bgcolor="#993333">
									<font class="NArialL"><font color="#FFFFFF">Shipped <bean:message key="label.mktgPartNumber"/></font></font>
								</td>
								<td width="15%" align="center" bgcolor="#993333">
									<font class="NArialL"><font color="#FFFFFF"><bean:message key="label.customerPartNumber"/></font></font>
								</td>
								<td width="20%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Description</font></font></td>
								<td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">UOM</font></font></td>
								<td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Req. Dock Date</font></font></td>
								<td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Sch. Ship Date</font></font></td>
                                <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Revised Ship Date</font></font></td>
								<td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Requested Quantity</font></font></td>
								<td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Quantity To be Shipped</font></font></td>
								<td colspan="2" width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Quantity Shipped</font></font></td>
								<td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Status</font></font></td>
							</tr>
							<% int i = 0; %>
							<nested:iterate id="cslt" property="lineitems"  type="com.scalar.chiptrack.operations.packingslip.CustomerShippingLineItems" indexId="lineItemIdx">

							<tr <%if( i++%2==0){%> bgcolor="#DEE1E2" <% } else {%> bgcolor="#FFFFFF" <%}%>>
								<td width="4%" align="center">
									<font class="NArialL">
											<input type="checkbox" name="selectLineitem" <%=cslt.getQtyPulled()>0 ? "CHECKED" : ""%> onclick="javascript:selectInventory(<%= ( i-1 )%>);"  class="NArialL"/>
									</font>
								</td>
								<td width="4%" align="center">
									<font class="NArialL"><nested:write property="lineitemNumber"/></font>
									<nested:hidden property="customerShippingLineItemId"/>
									<nested:hidden property="lineitemNumber"/>
									<nested:hidden property="lineItemId"/>
								</td>
                                <nested:hidden property="part_Number"/>
                                <nested:hidden property="parentPartNumber"/>
								<% if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MFG_PARTNO_PACKINGSLIP ) ) { %>
								<td width="15%" align="center" nowrap>
									<font class="NArialL">
										<nested:write property="part_Number"/>
									</font>

								</td>
                                <% }  %>
                                 <% if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MRKT_PARTNO_PACKINGSLIP ) ) { %>
                                <td width="15%" align="center" nowrap>
									<font class="NArialL">
										<nested:write property="mkt_Part_Number"/>
									</font>
								</td>
                                <% }  %>

                                <td width="15%" align="center" nowrap><font class="NArialL">

                                    <nested:define id="subPartNoList" property="substitutablePartNumbers" type="java.util.ArrayList"/>
                                        <% if (  isDisableSubstitutableList != null && isDisableSubstitutableList[(i-1)] == 1 ) { %>
                                            <nested:select property="shipped_Part_Number" multiple="true" styleClass="emptyList" disabled="true">
                                                <html:options collection="subPartNoList" property="value" labelProperty="label" />
                                            </nested:select>
                                        <% } else { %>
                                            <nested:select property="shipped_Part_Number" multiple="true" styleClass="emptyList">
                                                <html:options collection="subPartNoList" property="value" labelProperty="label" />
                                            </nested:select>
                                        <% } %>
                                </font></td>
								<td width="15%" align="center" nowrap>
                                    <nested:text property="customer_Part_Number" size="15" maxlength="50" styleClass="txfield"/>
                                </td>
								<td width="240" align="center">
									<font class="NArialL">
                                    <nested:textarea property="cool_Description" styleClass="txfield" rows="3" cols="20" />
									</font>
								</td>
								<td width="15%" align="center" nowrap>
                                    <nested:text property="units" size="8" maxlength="50" styleClass="txfield" />
								</td>
								<td width="10%" align="right" nowrap>
									<font class="NArialL"><nested:write property="cool_Requested_Date"/></font>
								</td>
								<td width="10%" align="right" nowrap>
									<font class="NArialL"><nested:write property="cool_Schedule_Date"/></font>
								</td>
                                <td width="10%" align="right" nowrap>
									<font class="NArialL"><nested:write property="cool_Revised_Date"/></font>
								</td>
								<td width="10%" align="right" nowrap>
									<font class="NArialL"><nested:write property="cool_Qty"/></font>
									<nested:hidden property="cool_Qty"/>
								</td>
								<td width="10%" align="right">
									<font class="NArialL"><nested:write property="qtyToShip"/></font>
									<nested:hidden property="qtyToShip"/>
								</td>
								<td width="10%" align=center >
									<font class="NArialL">
                                        <nested:greaterThan value="0" property="qtyPulled">
                                            <nested:text property="qtyPulled" size="8" maxlength="8" styleClass="txfield" />
                                        </nested:greaterThan>
                                        <nested:lessEqual value="0" property="qtyPulled">
                                            <nested:text property="qtyPulled" size="8" disabled="true" maxlength="8" styleClass="txfield" />
                                        </nested:lessEqual>
                                        <% if ( request.getParameter("mode") != null ) { %>
                                            <nested:hidden property="hiddenQtyPulled"/>
                                            <nested:hidden property="inventoryPulled"/>
                                        <% } else { %>
                                            <nested:hidden property="hiddenQtyPulled" value='<%=cslt.getQtyPulled()+""%>'/>
                                            <nested:hidden property="inventoryPulled" value='<%=cslt.getOrginalQtyPulled()+"" %>'/>
                                        <% }  %>
									<nested:hidden property="orginalQtyPulled"/>
									</font>
								</td>
								<td width="2%" align="right">&nbsp;</td>
								<td width="8%" align="center">
									<font class="NArialL"><bean:write name="packingSlipForm" property="status"/></font>
								</td>
							</tr>
							</nested:iterate>
							<input type= "hidden" name = "count" value="<%=i%>"/>
						</table>
					</td>
				</tr>
                <!-- NEW CODE ENDS HERE  -->
				<tr>
					<td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td>
				</tr>
				<tr>
					<td colspan=6 align=center>
						<chiptrack:restrictedLink functionality='<%=Functionality.PACKING_SLIP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:generatePackingSlip();' onmouseover="window.status='Click to Save Packing Slip';return true" onmouseout="window.status='';return true">
						<img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" title="Click here to Save Packing Slip">
						</chiptrack:restrictedLink>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="javascript:cancelAndGoBack();" onMouseOver="window.status='Click to go Back to Packing Slip Menu';return true" onMouseOut="window.status='';return true" Title="Click here to go Back to Packing Slip Menu"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif"></a>
					</td>
				</tr>
				<tr>
					<td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td>
				</tr>
				<tr>
				    <td colspan=6><img border='0' height='16' width='20' src="<%=chipTracContext%>/jsp/includes/images/arrow.gif">  Indicates Inventory can be Pulled for the Packing Slip
                    </td>
                </tr>
                <tr>
                    <td colspan=6><img border='0' height='16' width='20' src="<%=chipTracContext%>/jsp/includes/images/cancel_icon.gif"> Indicates no inventory available for the Part number
                    </td>
				</tr>
				<tr>
					<td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
				</tr>
			</table>
			</html:form>
            <BR><BR><BR>
        </TD>
		<TD bgcolor="#ffffff"><IMG height=40 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
	</TR>
</TABLE>
<!-- Footer starts here -->
<%@include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</body>
</html:html>